package com.outstanding.his.treatment.dao.impl;

import java.util.Collection;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.outstanding.his.treatment.dao.ITreatmentDao;
import com.outstanding.his.treatment.domain.ChineseMedicine;
import com.outstanding.his.treatment.domain.Treatment;
import com.outstanding.his.treatment.domain.WesternMedicine;

public class HibernateTreatmentDao extends HibernateDaoSupport implements
		ITreatmentDao {

	@Override
	public Treatment getTreatment(Integer treatmentId)
			throws DataAccessException {
		Treatment treatment = (Treatment) this.getSession().load(
				Treatment.class, treatmentId);
		return treatment;
	}

	@Override
	public Collection<Treatment> getTreatmentList() throws DataAccessException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Treatment submitTreatment(Treatment treatment)
			throws DataAccessException {
		this.getHibernateTemplate().saveOrUpdate(treatment);
		return treatment;
	}

	@Override
	public Treatment updateTreatment(Treatment treatment)
			throws DataAccessException {
		this.getHibernateTemplate().merge(treatment);
		return treatment;
	}

	@Override
	public void deleteWesternMedicine(WesternMedicine westernMedicine)
			throws DataAccessException {
		this.getHibernateTemplate().delete(westernMedicine);
	}

	@Override
	public void deleteChineseMedicine(ChineseMedicine chineseMedicine)
			throws DataAccessException {
		this.getHibernateTemplate().delete(chineseMedicine);
	}

}
